let name = localStorage.getItem("name");

document.querySelector(".uname").innerHTML = `${name}`;
axios
  .get(
    `http://cba.itlike.com/public/index.php?s=/api/goods/list&sortType=all&sortPrice=0&categoryId=0&goodsName=${name}&page=1`
  )
  .then(({ data: { data } }) => {
    console.log(data);
    data.list.data.forEach((ele) => {
      console.log(ele);
      let str = "";
      if (ele.line_price_max !== "0.00") {
        str = `<del>￥${ele.line_price_max}</del>`;
      }
      document.querySelector(".content").innerHTML += `
            <a href='../智慧商城/detailed.html' class="box" data-id=${ele.goods_id}>
            <img src="${ele.goods_image}" alt="" data-id=${ele.goods_id}>
            <p class="ellipsis-2" data-id=${ele.goods_id}>${ele.goods_name}</p>
            <p><span data-id=${ele.goods_id}>￥${ele.goods_price_max}</span>${str}</p>
        </a>
            `;
    });
    // document.querySelector('.content').innerHTML=
    document.querySelector(".content").addEventListener("click", function (e) {
      // console.log(item.goods_id);
      console.log(e.target.dataset.id);
      localStorage.setItem("data", e.target.dataset.id);
    });
  });
